鱼C论坛

 找回密码
 立即注册
查看: 3732|回复: 4

org命令是什么东东

[复制链接]
发表于 2012-3-13 08:36:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
如题,在emu8086的例题中都是org 100h,没有用我们在甲鱼大大视频中学的start:和end start语句。看了汇编金手指里面的解说也还是没搞懂,求高手指点迷津!!!
  1. name "hi-world"

  2. ; this example prints out  "hello world!"
  3. ; by writing directly to video memory.
  4. ; in vga memory: first byte is ascii character, byte that follows is character attribute.
  5. ; if you change the second byte, you can change the color of
  6. ; the character even after it is printed.
  7. ; character attribute is 8 bit value,
  8. ; high 4 bits set background color and low 4 bits set foreground color.

  9. ; hex    bin        color
  10. ;
  11. ; 0      0000      black
  12. ; 1      0001      blue
  13. ; 2      0010      green
  14. ; 3      0011      cyan
  15. ; 4      0100      red
  16. ; 5      0101      magenta
  17. ; 6      0110      brown
  18. ; 7      0111      light gray
  19. ; 8      1000      dark gray
  20. ; 9      1001      light blue
  21. ; a      1010      light green
  22. ; b      1011      light cyan
  23. ; c      1100      light red
  24. ; d      1101      light magenta
  25. ; e      1110      yellow
  26. ; f      1111      white



  27. org 100h

  28. ; set video mode   
  29. mov ax, 3     ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3)
  30. int 10h       ; do it!

  31. ; cancel blinking and enable all 16 colors:
  32. mov ax, 1003h
  33. mov bx, 0
  34. int 10h


  35. ; set segment register:
  36. mov     ax, 0b800h
  37. mov     ds, ax

  38. ; print "hello world"
  39. ; first byte is ascii code, second byte is color code.

  40. mov [02h], 'H'

  41. mov [04h], 'e'

  42. mov [06h], 'l'

  43. mov [08h], 'l'

  44. mov [0ah], 'o'

  45. mov [0ch], ','

  46. mov [0eh], 'W'

  47. mov [10h], 'o'

  48. mov [12h], 'r'

  49. mov [14h], 'l'

  50. mov [16h], 'd'

  51. mov [18h], '!'




  52. ; color all characters:
  53. mov cx, 12  ; number of characters.
  54. mov di, 03h ; start from byte after 'h'

  55. c:  mov [di], 11101100b   ; light red(1100) on yellow(1110)
  56.     add di, 2 ; skip over next ascii code in vga memory.
  57.     loop c

  58. ; wait for any key press:
  59. mov ah, 0
  60. int 16h

  61. ret
复制代码





                               
登录/注册后可看大图
该贴已经同步到 风剑河的微博
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-3-13 08:46:58 | 显示全部楼层
本帖最后由 莫名其妙 于 2012-3-13 08:47 编辑

百度了下   貌似是偏移的意思  贴上来一段



第一个程序不用ORG 100H时相当于:
0000:0000   CODE SEGMENT
START:
0000:0000   mov ax,offset message   注:这时 offset message值为0003H
0000:0003   message db 'this is'

第一个程序相当于:
0000:0000   CODE SEGMENT
0000:0000   ORG 100H
START:
0000:0100   mov ax,offset message   注:这时 offset message值为0103H
0000:0103   message db 'this is'

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-3-13 10:29:58 | 显示全部楼层
莫名其妙 发表于 2012-3-13 08:46
百度了下   貌似是偏移的意思  贴上来一段

emu里面能正常编译链接运行,而在cmd里面用masm命令就不行了,出错为:error a2034:must be in segment block
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-3-13 19:47:30 | 显示全部楼层
风剑河 发表于 2012-3-13 10:29
emu里面能正常编译链接运行,而在cmd里面用masm命令就不行了,出错为:error a2034:must be in segment  ...

应该是编译模式不一样吧  可能用CMD里的masm 需要用 assume ----code segment start;这种格式
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-3-14 14:30:22 | 显示全部楼层
查到点东西,网上说 org 100h是com程序不可缺少的东西,说这样的程序是com程序,至于什么是com程序,貌似还要啃进去一本书来能懂。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-3 21:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表